Cristiano Ronaldo scored a hat-trick for Portugal as he denied Fernando Hierros Spain victory with a stunning late free-kick in their World Cup Group B opener. Two days after Julen Lopetegui was fired Spain boss for agreeing a post-tournament move to Real Madrid, more pain lie in wait for the Spaniards as Ronaldo swerved a vicious shot into David de Geas corner to avert defeat in a spellbinding, topsy-turvy match. Ronaldo had earlier opened the scoring, a penalty in the fourth minute after Nacho felled him in the box, before Diego Costas bullying low finish dragged Spain back into the match. But just before the break De Gea made a terrible and uncharacteristic error, fumbling a zipping Ronaldo shot through his gloves and over the line. Another dose of adversity for Spain deal with. But Hierros men responded through Costa again, the Atletico Madrid striker smashing in from Sergio Busquets knockdown nine minutes after half-time, before Nacho redeemed himself with a stunning volley from the edge of the area that crashed in off both posts. For his part, Ronaldo was in largely anonymous in the second half, a spectator to Spains recovery, but he emerged from the shadows of this fascinating spectacle to define the games result and in doing so become just the fourth player to score at four World Cups. There had been so many questions raised in the build-up to this game about Spains mental state but this gutsy performance, in which they showed beautiful glimpses of their real ability, has provided a comprehensive answer, despite Ronaldos late blow. In other matches played on Friday, Egypt lost 1-0 to Poland in Group A while Iran beat Morocco by a similar score-line in Group B.